﻿/**

 @Name：layxwin 窗口管理模块
 @Author：Zxq
 @License：MIT
    
 */
layui.define(function (exports) {
    "use strict";
    var $ = layui.jquery, HIDE = '.layui-hide', taskbarHeight = 40, taskbarWidth = 48;
    var anims = ['layer-anim-00', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06'];

    //弹窗构造函数
    var WinLayx = function () {
        this.settings = {
            storeStatus: false,
            existFlicker: false,
            borderRadius: '0px',
            //controlStyle:'background-color:var(--win-title-bgcolor,var(--start-color));color:var(--win-title-fontcolor, #fff);',
            escKey: false,
            loadingText: '加载中...',
            maxLimit: {
                left: 0,
                right: 0,
                top: 0,
                bottom: taskbarHeight
            },
            position:'mc,-20',
            relateAttr: 'win-id',//窗口对应div属性名 
            anim: 0,     //平滑放大
            miniAnim: 0    //缩小动画0
        }
        this.minisizeAnim = ['anim-minisize0', 'anim-minisize1'];
        this.loadAnim = function (op) {
            if (op.anim != null) {
                !op.event && (op.event = {});
                !op.event.onload && (op.event.onload = {});
                op.event.onload.before = function (layxWindow, winform) {
                    if (winform.anim === null) return;
                    var animClass = 'layer-anim ' + anims[op.anim];
                    $(layxWindow).addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
                        $(this).removeClass(animClass);
                    });
                };
            }
        }
    };
    //配置
    WinLayx.prototype = {
        config: function (options) {
            this.settings = $.extend({}, this.settings, options || {})
            return layx.config(this.settings);
        },
        changeTaskbarMode: function (toMode, fromMode, auto) {//fromMode='setHide'表示任务栏隐藏，fromMode='cancelHide'表示取消任务栏隐藏,auto表示是否自动隐藏任务栏
            var option,left,top;
            switch(toMode){
                case 'top':
                    var t = (fromMode==='setHide' || auto ? 2 : taskbarHeight);
                    option = {
                        maxLimit: {
                            left: 0,
                            right: 0,
                            top: t,
                            bottom: 0
                        },
                        position:['mc',t/2],
                        moveLimit: {topOut:t}
                    };
                    if (fromMode==='setHide') top = 2-taskbarHeight;
                    else if (fromMode==='cancelHide') top = taskbarHeight-2;
                    else top = (auto ? 2 : taskbarHeight);
                    if (fromMode === 'left')
                        left = (auto ? -2 : -taskbarWidth);
                    break;
                case 'left':
                    var l = (fromMode==='setHide' || auto ? 2 : taskbarWidth);
                    option = {
                        maxLimit: {
                            left: l,
                            right: 0,
                            top: 0,
                            bottom: 0
                        },
                        position:['mc',0,l/2],
                        moveLimit: {topOut:0}
                    };
                    if (fromMode==='setHide') left = 2-taskbarWidth;
                    else if (fromMode==='cancelHide') left = taskbarWidth-2;
                    else left = (auto ? 2 : taskbarWidth);
                    if (fromMode === 'top')
                        top = (auto ? -2 : -taskbarHeight);
                    break;
                case 'right':
                    var r = (fromMode==='setHide' || auto ? 2 : taskbarWidth);
                    option = {
                        maxLimit: {
                            left: 0,
                            right: r,
                            top: 0,
                            bottom: 0
                        },
                        position:['mc',0,-r/2],
                        moveLimit: {topOut:0}
                    };
                    if (fromMode === 'left')
                        left = (auto ? -2 : -taskbarWidth);
                    if (fromMode === 'top')
                        top = (auto ? -2 : -taskbarHeight);
                    break;
                case 'bottom':
                default: 
                    var b = (fromMode==='setHide' || auto ? 2 : taskbarHeight);
                    option = {
                        maxLimit: {
                            left: 0,
                            right: 0,
                            top: 0,
                            bottom: b
                        },
                        position:['mc',-b/2],
                        moveLimit: {topOut:0}
                    };
                    if (fromMode === 'left')
                        left = (auto ? -2 : -taskbarWidth);
                    if (fromMode === 'top')
                        top = (auto ? -2 : -taskbarHeight);
                    break;
            }
            this.config(option);
            //所有已打开窗口top/left距离调整，相对于desktop桌面的位置保持不变，windows系统则在保持窗口全部在可视区域的前提下保持屏幕位置不变(如从底部切换到靠右，若窗口宽度大于可视区域宽度窗口会被改小，若有被任务栏挡住的，会调整位置)
            var winforms = this.windows();
            for(var id in winforms) {
                var $w = $('#layx-'+id);
                if (left) {
                    var l = left + parseInt($w.css('left'));
                    $w.css('left', l+'px');
                    winforms[id].area.left = l;
                }
                if (top) {
                    var t = top + parseInt($w.css('top'));
                    $w.css('top', t+'px');
                    winforms[id].area.top = t;
                }
                winforms[id] = $.extend({},winforms[id],option);
                if (winforms[id].status === 'max')
                    this.max(id);
                else if (winforms[id].status === 'min' && winforms[id].minBefore === 'max') {
                    this.max(id);
                    this.min(id);
                }
            }
        },
        //重置元素的事件
        resetEvent: function(event, selector, func, elem, selfonly) {
            if (typeof func != 'function') return;
            var othis = this;
            var fun = function (e) {
                if (layui.data('swui','lockscreen') === true) return false;
                !e && (e = window.event);
                if (selfonly && !$(e.target||e.srcElement).is(this)) {
                    layui.stope(e);
                    return false;
                }
                func.call(this, e);
            }
            if (elem) $(elem).off(event, selector).on(event, selector, fun);
            else $(selector).off(event).on(event, fun);
        },
        getIconHtml: function (icon, height) {
            if (!icon) return '';
            else if (icon.indexOf('<fa>')===0) {//以<fa>开头表示font-awesome图标
                return '<i class="fa ' + icon.substr(4) + ' fa-fw"></i>';
            }
            else if (icon.indexOf('<layui>')===0) {//以<layui>开头表示layui图标
                return '<i class="layui-icon ' + icon.substr(7) + '"></i>';
            }
            else {//默认为图片的路径
                if (height) return '<img src="' + icon + '" height="'+height+'px" />';
                return '<img src="' + icon + '" />';
            }
        },
        ContextMenu: function (items, cls, position) {
            if (!items || items.length === 0) return;
            var othis = this;
            var args = [].slice.call(arguments,4);
            var style = '';
            for(var property in position){
                style+=property+':'+position[property]+';';
            }
            //右键点击
            var div = '<ul class="' + cls + '" style="' + style + '">';
            $(items).each(function (index, item) {
                div += '<li'+function(){
                    var s = ' ';
                    if (item.childrens) {
                        s += 'class="parentmenu"';
                    }
                    else if (item.space) {//分隔符
                        s += 'class="separator"';
                    }
                    return s;
                }()+'>' + function(){
                    if (item.name) {
                        if (item.childrens && item.childrens.length > 0) {//存在子项,暂时只支持一级
                            var s = othis.getIconHtml(item.icon) + item.name + '<i class="layui-icon layui-icon-right"></i>';
                            s += '<ul class="'+HIDE+'">';
                            $(item.childrens).each(function(index, item){
                                if (item.space) {//分隔符
                                    s += '<li class="separator"></li>';
                                }
                                else s+='<li>'+item.name+'</li>';
                            });
                            s += '</ul>';
                            return s;
                        }
                        else //右键选项值不变情况下
                            return othis.getIconHtml(item.icon) + item.name;
                    }
                    else return '';
                }() + '</li>';
            });
            div += '</ul>';
            //移除之前任务项右键菜单
            $('.'+cls).remove();
            //渲染当前任务项右键菜单
            div = $(div).appendTo($(document.body));
            //绑定单击回调函数
            othis.resetEvent('click', 'ul.'+cls+' li:not(.separator)', function (){
                var index = $(this).index();
                if (!$(this).parent().hasClass(cls)) {//子项
                    var ind = $(this).parent().parent().index();
                    var item = items[ind].childrens[index];
                    if (typeof item.handler != 'function')
                        return;
                    //调用回调函数
                    item.handler.call(this, args, item);
                }
                else if (items[index].name) {
                    if (typeof items[index].handler != 'function')
                        return;
                    //调用回调函数
                    items[index].handler.call(this, args, items[index]);
                }
                div.remove();
            });
            //阻止右键菜单冒泡
            $('ul.'+cls+' li').on('click mousedown', layui.stope);
            othis.resetEvent('mouseenter', 'ul.'+cls+' li.parentmenu', function (){
                var ul = $(this).children('ul');
                ul.removeClass(HIDE).removeClass('left');;
                if (ul.width()+ul.offset().left>winWidth)
                    ul.addClass('left');
            });
            othis.resetEvent('mouseleave', 'ul.'+cls+' li.parentmenu', function (){
                $(this).children('ul').addClass(HIDE);
            });
        },
        openPageNotIframe: function (option) {//以内容形式打开html页面
            $.get(option.url, {}, function (content) {
                layx.open({
                    id: option.id,
                    title: option.title,
                    content:'',
                    relateElem: option.relateElem,
                    event:option.event
                });
                $("#layx-"+option.id+"-html").append(content);
                //tab页面专用index来指定跳到哪个tab选项卡
                if (option.index) $("#layx-"+option.id+" .swui-tab-nav").children('li').eq(option.index).trigger('click');
            });
        },
        open: function (options,callback) {
            var op = $.extend({}, this.settings, options);
            this.loadAnim(op);
            var win;
            if (op.url && op.noIframe) {//url页面不以iframe方式打开，而是读取后追加到窗口
                if (op.index != null)
                    op.url+='#'+op.index;
                $.get(op.url, {}, function (content) {
                    //tab页面专用index来指定跳到哪个tab选项卡
                    if (op.index != null) {
                        content = '<script>var tabIndex='+op.index+';</script>' + content;
                    }
                    !op.event && (op.event = {});
                    !op.event.onload && (op.event.onload = {});
                    op.event.onload.after = function (layxWindow, winform) { //新打开窗口才追加内容
                        $("#layx-"+op.id+"-html").append(content);
                    };
                    win = layx.open(op);
                    if (typeof callback === 'function')
                        callback(win);
                });
            }
            else {
                if (op.url && !op.noIframe && !op.type) {//iframe打开方式
                    op.type = 'url';
                }
                op.useFrameTitle = (op.title === true ? true : false);
                win = layx.open(op);
                if (typeof callback === 'function')
                    callback(win);
            }
            return win;
        },
        html: function (id, title, content, options) {
            var op = $.extend({}, this.settings, options);
            this.loadAnim(op);
            return layx.html(id, title, content, op);
        },
        iframe: function (id, title, url, options) {
            var op = $.extend({}, this.settings, options);
            return layx.iframe(id, title, url, op);
        },
        group: function (id, frames, frameIndex, options) {
            var op = $.extend({}, this.settings, options);
            if (!frames || frames.length == 0) {
                //新建标签页
                frames = [{title:'新标签页',
                    type:'url',
                    url:'',
                    closable:true}]
            }
            return layx.group(id, frames, frameIndex, op);
        },
        getBrowserOption: function (options) {
            var othis = this;
            if (!options) options = {code:'browser'};
            if (!options.frames || options.frames.length === 0) {
                options.frames=[{title:'新标签页',
                                type:'url',
                                url:'about:blank',
                                useFrameTitle:true,
                                closable:true}];
            }
            !options.title && (options.title='浏览插件');
            options.frameIndex = typeof options.frameIndex === "number" ? (options.frameIndex > options.frames.length ? 0 : options.frameIndex) : 0;
            var op = {
                    type: 'group',
                    icon:'<fa>fa-internet-explorer',
                    refreshMenu:false,
                    openable:true,
                    history:true,
                    httpurl:true,
                    toolBar:'<div class="swui-browser-icon swui-browser-back disable" title="点击可后退，右键可查看历史记录"><i class="layui-icon layui-icon-return"></i></div><div class="swui-browser-icon swui-browser-go disable" title="点击可后退，右键可查看历史记录"><i class="layui-icon layui-icon-return"></i></div><div class="swui-browser-icon swui-browser-refresh" title="重新加载此页"><i class="layui-icon layui-icon-refresh"></i></div><div class="swui-browser-icon swui-browser-menu" title="更多设置，加书签等等功能"><i class="layui-icon layui-icon-more-vertical"></i></div><div class="swui-browser-url"><input class="layui-input" name="url" value="" placeholder="在本站中搜索，或者输入一个网址" /></div>',
                    //mergeTitle:true,
                    //title:'浏览器窗口插件',
                    event:{
                        onswitch:{
                            after:function(layxWindow, winform, fid){
                                var frameConfig;
                                for (var i=0;i<winform.frames.length;i++) {
                                    if (winform.frames[i].id === fid) {
                                        frameConfig = winform.frames[i];
                                        break;
                                    }
                                }
                                var obj = $(layxWindow).find('div.swui-browser-url input');
                                if (!frameConfig) {
                                    obj.val('');
                                    $(layxWindow).find('.swui-browser-back').addClass('disable');
                                    $(layxWindow).find('.swui-browser-go').addClass('disable');
                                    return;
                                }
                                obj.val(frameConfig.url);
                                if (frameConfig.hisIndex === 0) {
                                    $(layxWindow).find('.swui-browser-back').addClass('disable');
                                }
                                else {
                                    $(layxWindow).find('.swui-browser-back').removeClass('disable');
                                }
                                if (frameConfig.hisIndex === frameConfig.history.length-1) {
                                    $(layxWindow).find('.swui-browser-go').addClass('disable');
                                }
                                else {
                                    $(layxWindow).find('.swui-browser-go').removeClass('disable');
                                }
                            }
                        },
                        ongroup:{
                            insert:function(layxWindow, winform, fid, url) {
                                $(layxWindow).find('div.swui-browser-url input').val(url);
                                $(layxWindow).find('.swui-browser-back').addClass('disable');
                                $(layxWindow).find('.swui-browser-go').addClass('disable');
                            }
                        },
                        onload:{
                            after:function(layxWindow, winform){
                                winform.anim = null;
                                var obj = $(layxWindow).find('div.swui-browser-url input');
                                var getFrameConfig = function (id){
                                    var config;
                                    for (var i=0;i<winform.frames.length;i++) {
                                        if (winform.frames[i].id === id) {
                                            config = winform.frames[i];
                                            break;
                                        }
                                    }
                                    return config;
                                }
                                ,goHistory = function (id, index) {//跳转历史
                                    var frameConfig = getFrameConfig(id);
                                    if (index === 'prev')
                                        index = frameConfig.hisIndex-1;
                                    else if (index === 'next')
                                        index = frameConfig.hisIndex+1;
                                    else if (typeof index !== 'number') 
                                        return;
                                    if (index < 0)
                                        index = 0;
                                    else if (index > frameConfig.history.length-1)
                                        index = frameConfig.history.length - 1;
                                    if (frameConfig.hisIndex === index)
                                        return;
                                    frameConfig.hisIndex = index;
                                    var url = frameConfig.history[frameConfig.hisIndex].url;
                                    obj.val(url);
                                    layx.setGroupUrl(winform.id,frameConfig.id,url);
                                    if (frameConfig.hisIndex === 0) {
                                        $(layxWindow).find('.swui-browser-back').addClass('disable');
                                    }
                                    else {
                                        $(layxWindow).find('.swui-browser-back').removeClass('disable');
                                    }
                                    if (frameConfig.hisIndex === frameConfig.history.length-1) {
                                        $(layxWindow).find('.swui-browser-go').addClass('disable');
                                    }
                                    else {
                                        $(layxWindow).find('.swui-browser-go').removeClass('disable');
                                    }
                                };
                                othis.resetEvent('keydown', obj, function(e){
                                    var e = e || window.event;
                                    if (e.keyCode == 13) {
                                        //浏览页面跳转
                                        var selectTitle = $(layxWindow).find(".layx-group-title[data-enable='1']");
                                        if (selectTitle.length === 0) return;
                                        var id = selectTitle.data('frameid')+'';
                                        layx.setGroupUrl(winform.id,id,$(this).val());
                                        if (getFrameConfig(id).hisIndex > 0)
                                            $(layxWindow).find('.swui-browser-back').removeClass('disable');
                                        $(layxWindow).find('.swui-browser-go').addClass('disable');
                                    }
                                    layui.stope(e);
                                });
                                othis.resetEvent('mouseup', '.swui-browser-icon:not(.disable)', function (e) {
                                    var selectTitle = $(layxWindow).find(".layx-group-title[data-enable='1']");
                                    if (selectTitle.length === 0) return;
                                    var id = selectTitle.data('frameid')+'';
                                    switch (e.button) {
                                        case 0://左键
                                            if ($(this).is('.swui-browser-back')) {
                                                goHistory(id,'prev');
                                            }
                                            else if ($(this).is('.swui-browser-go')) {
                                                goHistory(id,'next');
                                            }
                                            else if ($(this).is('.swui-browser-refresh')) {
                                                layx.setGroupUrl(winform.id, id, getFrameConfig(id).url);
                                            }
                                            else if ($(this).is('.swui-browser-menu')) {
                                                layer.msg('更多功能，比如书签、历史记录等等，<span style="color:red;">敬请期待</span>');
                                            }
                                            break;
                                        case 2://右键
                                            var frameConfig = getFrameConfig(id);
                                            if ($(this).is('.swui-browser-back')) {
                                                var backs = [];
                                                for (var i=frameConfig.hisIndex-1;i>=0;i--){
                                                    backs.push({
                                                        name: frameConfig.history[i].name, 
                                                        index: i,
                                                        handler: function (args,item) {
                                                            goHistory(id,item.index);
                                                        }
                                                    })
                                                }
                                                var pos = $(this).offset();
                                                othis.ContextMenu(backs, 'app-contextmenu',{left:(pos.left-8)+'px',top:(pos.top+30)+'px'});
                                            }
                                            else if ($(this).is('.swui-browser-go')) {
                                                var goes = [];
                                                for (var i=frameConfig.hisIndex+1;i<frameConfig.history.length;i++){
                                                    goes.push({
                                                        name: frameConfig.history[i].name, 
                                                        index: i,
                                                        handler: function (args,item) {
                                                            goHistory(id,item.index);
                                                        }
                                                    })
                                                }
                                                var pos = $(this).offset();
                                                othis.ContextMenu(goes, 'app-contextmenu',{left:pos.left+'px',top:(pos.top+30)+'px'});
                                            }
                                            break;
                                    }
                                }, layxWindow);
                            }
                        }
                    }
                }
            return $.extend({}, this.settings, options, op);
        },
        openBrowserWindow: function (options, isnew){
            if (!isnew) {
                var wins = layx.windows();
                if (wins.length === 0) {
                    isnew = true;
                }
                else {
                    var win;
                    for(var key in wins) {
                        if (wins[key].type==='group' && wins[key].closable===true && wins[key].openable===true){
                            win = wins[key];
                        }
                    }
                    if (!win) isnew = true;
                    else {
                        win.addGroupItem({title:options.title,
                            type:'url',
                            url:options.url,
                            icon:this.getIconHtml(options.icon),
                            useFrameTitle:options.title ? false : true,
                            closable:true});
                        return true;
                    }
                }
            }
            if (isnew) {
                options.frames = [{title:options.title,
                                type:'url',
                                url:options.url,
                                icon:this.getIconHtml(options.icon),
                                useFrameTitle:options.title ? false : true,
                                closable:true}];
                options = this.getBrowserOption(options);
            }
            return options;
        },
        windows: function () {
            return layx.windows();
        },
        getWindow: function (id) {
            return layx.getWindow(id);
        },
        getFocusWindow: function (){
            return layx.getFocusWindow();
        },
        getFocusWindowList: function (filterType){
            return layx.getFocusWindowList(filterType);
        },
        destroy: function (id, params, force) {
            layx.destroy(id, params, force);
        },
        visual: function (id, status, params) {
            layx.visual(id, status, params);
        },
        preview: function (id) {
            var windows = layx.windows();
            for(var winid in windows) {
                var winform = windows[winid];
                var layxWindow = $("#layx-" + winid);
                if (winid === id && winform.status==='min')
                    layxWindow.removeClass('layx-hide-statu');
                else if (winid !== id && winform.status!=='min' && !layxWindow.hasClass('layx-hide-statu')) {
                    layxWindow.addClass('layx-hide-statu');
                }
            }
        },
        endPreview: function () {
            var windows = layx.windows();
            for(var winid in windows) {
                var winform = windows[winid];
                var layxWindow = $("#layx-" + winid);
                if (winform.status!=='min' && layxWindow.hasClass('layx-hide-statu')) {
                    layxWindow.removeClass('layx-hide-statu');
                }
                else if (winform.status==='min' && !layxWindow.hasClass('layx-hide-statu')) {
                    layxWindow.addClass('layx-hide-statu');
                }
            }
        },
        min: function (id) {
            layx.min(id);
        },
        minAll: function (type) {
            var wins = layx.windows();
            var ismin = false;
            switch (type) {
                case 'min':
                    ismin = true;
                    break;
                case 'restore':
                    ismin = false;
                    break;
                default:
                    for(var w in wins){
                        if (wins[w].status!='min') {
                            ismin = true;
                            break;
                        }
                    }
                    break;
            }
            for(var w in wins){
                if (!ismin && wins[w].status=='min')
                    layx.restore(wins[w].id);
                else if (ismin && wins[w].status!='min')
                    layx.min(wins[w].id);
            }
        },
        max: function (id) {
            layx.max(id);
        },
        setTitle: function (id, title, useFrameTitle) {
            layx.setTitle(id, title, useFrameTitle);
        },
        flicker: function (id) {
            layx.flicker(id);
        },
        restore: function (id) {
            layx.restore(id);
        },
        updateZIndex: function (id) {
            layx.updateZIndex(id);
        },
        updateMinLayout: function () {
            layx.updateMinLayout();
        },
        stickToggle: function (id) {
            layx.stickToggle(id);
        },
        setPosition: function (id, position) {
            layx.setPosition(id, position);
        },
        getFrameContext: function (id) {
            return layx.getFrameContext(id);
        },
        getParentContext: function (id) {
            return layx.getParentContext(id);
        },
        setContent: function (id, content, cloneElementContent) {
            layx.setContent(id, content, cloneElementContent);
        },
        setUrl: function (id, url) {
            layx.setUrl(id, url);
        },
        setGroupContent: function (id, frameId, content, cloneElementContent) {
            layx.setGroupContent(id, frameId, content, cloneElementContent);
        },
        setGroupTitle: function (id, frameId, title, useFrameTitle) {
            layx.setGroupTitle(id, frameId, title, useFrameTitle);
        },
        setGroupUrl: function (id, frameId, url) {
            layx.setGroupUrl(id, frameId, url);
        },
        setGroupIndex: function (id, frameId) {
            layx.setGroupIndex(id, frameId);
        },
        getGroupFrameContext: function (id, frameId) {
            return layx.getGroupFrameContext(id, frameId);
        },
        destroyAll: function () {
            layx.destroyAll();
        },
        tip: function (msg, target, direction, options) {
            var op = $.extend({}, this.settings, options);
            layx.tip(msg, target, direction, op);
        },
        msg: function (msg, options) {
            var op = $.extend({}, this.settings, options);
            return layx.msg(msg, op);
        },
        alert: function (title, msg, yes, options) {
            var op = $.extend({}, this.settings, {controlStyle:'height:40px;',zIndex:40000000,focusToReveal:false,shadable:0.3,resizePosition:true}, options);
            return layx.alert(title, msg, yes, op);
        },
        confirm: function (title, msg, yes, options) {
            var op = $.extend({}, this.settings, {controlStyle:'height:40px;',dialogIcon:'help',zIndex:40000000,focusToReveal:false,shadable:0.3,resizePosition:true}, options);
            return layx.confirm(title, msg, yes, op);
        },
        prompt: function (title, msg, yes, defaultValue, options) {
            var op = $.extend({}, this.settings, {controlStyle:'height:40px;',zIndex:40000000,focusToReveal:false,shadable:0.3,resizePosition:true}, options);
            return layx.prompt(title, msg, yes, defaultValue, op);
        },
        load: function (id, msg, options) {
            var op = $.extend({}, this.settings, options);
            return layx.load(id, msg, op);
        },
        multiLine: function (f) {
            return layx.multiLine(f);
        },
        reloadFrame: function (id) {
            layx.reloadFrame(id);
        },
        refresh: function (id) {
            layx.refresh(id);
        },
        reloadGroupFrame: function (id, frameId) {
            layx.reloadGroupFrame(id, frameId);
        },
        setButtonStatus: function (id, buttonId, isEnable) {
            layx.setButtonStatus(id, buttonId, isEnable);
        },
        updateFloatWinPosition: function (id, direction) {
            layx.updateFloatWinPosition(id, direction);
        },
        getElementPos: function (ele) {
            return layx.getElementPos(ele);
        },
        destroyInlay: function (id) {
            layx.destroyInlay(id);
        },
        checkVisual: function (pEle, ele, allContain) {
            return layx.checkVisual(pEle, ele, allContain);
        },
        getButton: function (id, buttonId) {
            return layx.getButton(id, buttonId);
        },
        setSize: function (id, area) {
            layx.setSize(id, area);
        },
        setControlStyle: function (style, id) {
            layx.setControlStyle(style, id);
        },
        setStyle: function (style) {
            layx.setStyle(style);
        }
    }

    window.layxwin = new WinLayx();

    exports('layxwin', {});

    delete layui.layxwin;
});